<?php

namespace App\Http\Controllers\Api;


use App\Exceptions\ApiException;
use App\Exceptions\MyException;
use App\Exceptions\TestException;
use App\Http\Controllers\Controller;
use App\Http\Requests\CouponsPost;
use App\Models\Users;
use function dump;
use Illuminate\Http\Request;

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Tymon\JWTAuth\Facades\JWTAuth;

class AuthorizationsController extends AController
{

    /**
     * @description 密码登录
     * @param LoginRequest $loginRequest
     * @return \Illuminate\Http\JsonResponse
     * @throws UserException
     */
    public function login(Request $request)
    {

        throw new TestException("cao你吗",23);
        exit;
          $users=Users::get();
       dump($users);
           //传入对象得到token
          $JwtToken=Auth::guard('user')->setUser($users)->fromUser($users);
          $JwtToken2=Auth("user")->setUser($users)->fromUser($users);
           $JwtToken3=JWTAuth::fromUser($users); //直接获得token
          //获取对象
          $user1=Auth::guard("user")->user();
          $user2=Auth("user")->user();
          $user3=Auth::user(); //使用的前提是需要设置auth中默认守为是user
         // $user4=JWTAuth::toUser(JWTAuth::getToken());//验证

        dump($JwtToken2);

       // return response()->json(['code'=>1,'message' => "fuck"]);
    }

    public function test(Request $request)
    {
        dump(JWTAuth::refresh());
        $this->throw_error("fuck",1);
    }

}
